﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Housing;

public partial class StreetCenter_ManageAdmissibility : System.Web.UI.Page
{
    Admissibility admissibility = new Admissibility();
    protected void Page_Load(object sender, EventArgs e)
    {
        //Session["UserId"] = "sbaiyun";
        //Session["UserName"] = "15";
        //Session["UserType"] = "街道办事处";
        //Session["UserStreet"] = "西门";
        if (Session["UserId"] == null)
        {
            WebHelper.AlertAndRedirect("重新登录","../login.aspx");
        }
        
    }
    protected void PageBind()
    {
        //DataSet ds = admissibility.GetAdmissibilityForCheck(Session["UserStreet"].ToString());
        //gvstreetshow.DataSource = ds;
        //gvstreetshow.DataBind();
    }
    protected void gvstreetshow_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName.ToLower() == "del")
        {
            int succ = admissibility.DeleteAdmissibility(Convert.ToInt32(e.CommandArgument.ToString()));
            if (succ>0)
                PageBind();
            else
                WebHelper.Alert("删除失败，请重新操作！");
        }
        if (e.CommandName.ToLower() == "commit")
        {
            Apply apply = new Apply();
            string id = e.CommandArgument.ToString();
            apply.GetApplyById(id);
            apply.apply_passed = 2;
            int succ=apply.UpdateAApplyByApplyId(apply);
            if (succ>0)
                PageBind();
            else
                WebHelper.Alert("网络延时，请重新操作");
        }
		if (e.CommandName.ToLower() == "quickcommit")
        {
            string id = e.CommandArgument.ToString();
            string a = "";
            admissibility.SetApplypassed(id);
            int succ = Apply.Update_apply_checkstate_ByApply_id(id,"5");
            int succ2 = Apply.UpdateApply_passedByApply_noid(id, "2");
            if (succ > 0 && succ2>0)
                PageBind();
            else
                WebHelper.Alert("网络延时，请重新操作");
        }
    }
    protected void gvstreetshow_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        LinkButton del = (LinkButton)e.Row.FindControl("lkbtndel");
        if(del!=null)
            del.Attributes.Add("onclick", "return confirm('您确认要删除此受理单吗？');");
        
    }
    protected bool AllowView(int noid, object applyid)
    {
        if (applyid == DBNull.Value)
            return false;
        else
        {
            Apply apply = new Apply(applyid.ToString());
            if (apply.apply_passed == 1)
                return true;
            else
                return false;
        }
    }
}
